//
//  YCTrainPlanCell.m
//  YCSchool
//
//  Created by yanglinxia on 16/4/27.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCTrainPlanCell.h"


@interface YCTrainPlanCell()
///背景
@property (weak, nonatomic) IBOutlet UIView *bgView;
///日
@property (weak, nonatomic) IBOutlet UILabel *dayLabel;
///月
@property (weak, nonatomic) IBOutlet UILabel *monthLabel;
///训练内容
@property (weak, nonatomic) IBOutlet UILabel *trainContentLabel;
///今日训练容器view
@property (weak, nonatomic) IBOutlet UIView *todayTrainContainerView;
///今日训练时间
@property (weak, nonatomic) IBOutlet UILabel *todayTrainTimeLabel;
///训练时间
@property (weak, nonatomic) IBOutlet UILabel *trainTiemLabel;
///已完成
@property (weak, nonatomic) IBOutlet UIButton *trainFinishButton;

@end

@implementation YCTrainPlanCell

- (void)awakeFromNib {
    // Initialization code
    
    self.bgView.layer.cornerRadius = 5;
    self.bgView.layer.masksToBounds = YES;
    
    // 选中时背景为0x00b4ff
}

- (void)setItemModel:(YCTrainPlanModel *)itemModel
{
    _itemModel = itemModel;
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:itemModel.addtime];
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    fmt.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    NSString *str = [fmt stringFromDate:date];
    
    // 时间处理
    NSInteger hour = [NSDate yc_getHourIntegerFromDateString:itemModel.timehour formatter:@"HH:mm"];
    NSInteger minute = [NSDate yc_getMinuteIntegerFromDateString:itemModel.timehour formatter:@"HH:mm"];
    if (hour > 12) {
        itemModel.timehour = [NSString stringWithFormat:@"下午:%zd:%02zd",(hour - 12),minute];
    } else {
        itemModel.timehour = [NSString stringWithFormat:@"上午:%zd:%02zd",hour,minute];
    }
    
    UIColor *finishColor = [UIColor lightGrayColor];
    if (itemModel.finishmark) {
        self.todayTrainContainerView.hidden = YES;
        self.trainTiemLabel.hidden = YES;
        self.trainFinishButton.hidden = NO;
        self.dayLabel.textColor = finishColor;
        self.monthLabel.textColor = finishColor;
        self.trainContentLabel.textColor = finishColor;
    } else {
        
        if (itemModel.isTodayTrain) {
            self.bgView.backgroundColor = [UIColor yc_colorWithRed:115 Green:178 Blue:250];
            self.todayTrainContainerView.hidden = NO;
            self.trainTiemLabel.hidden = YES;
            self.trainFinishButton.hidden = YES;
            self.todayTrainTimeLabel.textColor = [UIColor whiteColor];
            self.dayLabel.textColor = [UIColor whiteColor];
            self.monthLabel.textColor = [UIColor whiteColor];
            self.trainContentLabel.textColor = [UIColor whiteColor];
        } else {
            self.bgView.backgroundColor = [UIColor whiteColor];
            self.todayTrainContainerView.hidden = YES;
            self.trainTiemLabel.hidden = NO;
            self.trainFinishButton.hidden = YES;
            self.todayTrainTimeLabel.textColor = [UIColor lightGrayColor];
            self.dayLabel.textColor = [UIColor blackColor];
            self.monthLabel.textColor = [UIColor lightGrayColor];
            self.trainContentLabel.textColor = [UIColor blackColor];
            
        }
    }
    self.dayLabel.text = [NSString stringWithFormat:@"%zd",itemModel.timeday];
    self.monthLabel.text = itemModel.timemonth;
    self.trainContentLabel.text = itemModel.title;
    self.todayTrainTimeLabel.text = itemModel.timehour;
    self.trainTiemLabel.text = itemModel.timehour;
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
